package com.suiwei.webservice.base.wsClient.client;

import com.suiwei.webservice.base.wsClient.autoGeneration.GreetWebService;
import com.suiwei.webservice.base.wsClient.interceptor.ClientLoginInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
/**
 * @author suiwei
 * @date 2023/4/24 21:20
 * 基于代理的方式，带验证
 */
public class CXFClientProxy {
  public static void main(String[] args) throws Exception {
    String address = "http://127.0.0.1:9090/greet?wsdl";
    JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
    jaxWsProxyFactoryBean.setAddress(address);
    jaxWsProxyFactoryBean.setServiceClass(GreetWebService.class);
    jaxWsProxyFactoryBean.getOutInterceptors().add(new ClientLoginInterceptor("suiwei", "suiwei"));
    GreetWebService greetWebService = (GreetWebService) jaxWsProxyFactoryBean.create();
    String result = greetWebService.greeting("隋伟");
    System.out.println(result);
  }
}
